<?php

class AreaAction extends Action{
	
	function area_proc(){
		$id = $_POST['id'];
		$condition = array();
		
		if($id != "0"){
			$condition = "prov_id = $id";
			$city = d("city");		
			$result = $city->where($condition)->findall();
			
			$str = "prov_id";
		}
		else {
			
			$prov = d("province");
			$result = $prov->findall();
			$str ="";
		}
		
		foreach ($result as $arr){
			foreach ($arr as $k => $v){
				if($k != $str){
					$result2[] = $v;
				}
			}				
			$result3[] = $result2;
			$result2 = "";
		}

		//dump($result);
		//dump($result3);

//		$j = spClass(Services_JSON);
//		print_r($j->encode($result3));			
		$this->ajaxReturn($result3,"",1);
	}
}
?>